<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head >
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!-- th:replace="~{common/public::common-public}" -->
              <link th:href="@{/web/css/header.css}" rel="stylesheet">
        <link th:href="@{/web/css/managermain.css}" rel="stylesheet">
        <link th:href="@{/web/css/courseTable.css}" rel="stylesheet">
      <script type="text/javascript" src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<title>Insert title here</title>
    <meta charset="utf-8">
</head>
<body>
<div class="header" th:insert="~{common/kuangjia::header}"></div>
<div class="diceng">
		<div class="caidan">
			<ul>
				<li><a th:href="@{/user/main}">首页</a></li>
				<li><a th:href="@{/user/getjsall}">选课系统</a></li>
				<li><a th:href="@{/user/getsywall}">成绩管理</a></li>
				<li><a th:href="@{/user/getwuqiall}">活动公告</a></li>
				<li><a th:href="@{/manong/exit}">退出登录</a></li>
			</ul>
		</div>
		<div class="main">
		
    <table border="1" style="height:500px;width:800px">
    <caption><h1>课程表</h1></caption>
        <thead>
            <tr>
                <th>时间</th>
                <th>星期一</th>
                <th>星期二</th>
                <th>星期三</th>
                <th>星期四</th>
                <th>星期五</th>
            </tr>
        </thead>
        <tbody id="myTbody">
            <!-- 表格内容将由脚本动态生成 -->
        </tbody>
    </table>
    </div>
    </div>
	    <script th:inline="javascript">
	    var xhr = new XMLHttpRequest();
     console.log(xhr)
     xhr.open("GET", "/manong/getCourseTableBySno")
     
     xhr.send()
     xhr.onreadystatechange=function(){
    	 if(xhr.readyState==4){
    		 //console.log("解析完成",JSON.parse(xhr.responseText))
  				var course=xhr.responseText;
    		 course=JSON.parse(course);
    		 console.log(course)
    		 
    	// console.log(xhr.readyState)
    	     var tbody=document.getElementById('myTbody')
    	     for(var i=1;i<=4;i++){
    	     	var tr=document.createElement('tr')
    	     	var td=document.createElement('td')
    	     	td.innerHTML='第'+i+'节课';
    	     	tr.appendChild(td)
    	     	 for(var k=1;k<=5;k++){
        			 var td=document.createElement('td')
        			 for(var c=0;c<course.length;c++){
        				 if(course[c].week==k&&course[c].jieci==i){
        					 td.innerHTML=course[c].course+'<br>@'+course[c].teacher+'<br>@'+course[c].classroom;
        					 tr.appendChild(td)
        				 }
        				 else {
        			 	     	tr.appendChild(td)
        				 }
        			 }
        			 }
    	     	tbody.appendChild(tr)
    	     	}	 
    	     }
    	 }
    </script>
</body>
</html>